﻿namespace OP20.ViewModels
{
    public class PingBiViewModel : BaseViewModel
    {


        public PingBiViewModel(IRegionManager regionManager) : base(regionManager)
        {

            //开启定时器任务
            DispatcherTimer dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
            dispatcherTimer.Tick += OnTick;
            dispatcherTimer.Start();
        }

        private void OnTick(object? sender, EventArgs e)
        {
            bPcDisabledText = SystemPLCToPC_Global.bPcDisabled ? "PC屏蔽中" : "PC屏蔽";
            bCcdDisabledText = SystemPLCToPC_Global.bCcdDisabled ? "CCD屏蔽中" : "CCD屏蔽";
            bDryRunningText = SystemPLCToPC_Global.bDryRunning ? "空跑中" : "空跑模式";
            BoolPCDisabled = SystemPLCToPC_Global.bPcDisabled;
            BoolCCDDisabled = SystemPLCToPC_Global.bCcdDisabled;
            BoolDryRunning = SystemPLCToPC_Global.bDryRunning;
        }


        private DelegateCommand<string> _PinBiCommand;
        public DelegateCommand<string> PinBiCommand =>
            _PinBiCommand ?? (_PinBiCommand = new DelegateCommand<string>(ExecutePinBiCommand));

        void ExecutePinBiCommand(string parameter)
        {
            switch (parameter)
            {
                case "ST01屏蔽":
                    ST1Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST02屏蔽":
                    ST2Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST03屏蔽":
                    ST3Station_Global.stationPCToPLC.bDisableBT = true;
                    break;

                case "ST04屏蔽":
                    ST4Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST05屏蔽":
                    ST5Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST06屏蔽":
                    ST6Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST08屏蔽":
                    ST8Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST10屏蔽":
                    ST10Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST11屏蔽":
                    ST11Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST12屏蔽":
                    ST12Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST13屏蔽":
                    ST13Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST14屏蔽":
                    ST14Station_Global.stationPCToPLC.bDisableBT = true;
                    break;
                case "ST15屏蔽":
                    ST15Station_Global.stationPCToPLC.bDisableBT = true;
                    break;

                

                case "LED灯关闭":
                    SystemPCToPLC_Global.bLEDPowerBtn = true;
                    break;
                case "蜂鸣器关闭":
                    break;


               

                case "机械臂上药屏蔽":
                    SystemPCToPLC_Global.bRobotDisableBtn = true;
                    break;
                case "ST1称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[1] = true;
                    break;
                case "ST2测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[2] = true;
                    break;
                case "ST5测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[3] = true;
                    break;
                case "ST5压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[4] = true;
                    break;
                case "ST6称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[5] = true;
                    break;
                case "ST10压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[6] = true;
                    break;
                case "ST11称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[7] = true;
                    break;
                case "ST13测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[8] = true;
                    break;
                case "ST13压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[9] = true;
                    break;
                case "ST13外径屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[10] = true;
                    break;


                case "载具1屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[32] = true;
                    break;

                case "载具2屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[33] = true;
                    break;

                case "载具3屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[34] = true;
                    break;
                case "载具4屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[35] = true;
                    break;
                case "载具5屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[36] = true;
                    break;
                case "载具6屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[37] = true;
                    break;
                case "载具7屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[38] = true;
                    break;
                case "载具8屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[39] = true;
                    break;
                case "载具9屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[40] = true;
                    break;
                case "载具10屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[41] = true;
                    break;
                case "载具11屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[42] = true;
                    break;
                case "载具12屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[43] = true;
                    break;
                case "载具13屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[44] = true;
                    break;
                case "载具14屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[45] = true;
                    break;
                case "载具15屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[46] = true;
                    break;
                case "安全门屏蔽":
                    SystemPCToPLC_Global.bDoorByPass = true;
                    break;
                default:
                    break;


            }
        }

        private DelegateCommand<string> _UnPinBiCommand;
        public DelegateCommand<string> UnPinBiCommand =>
            _UnPinBiCommand ?? (_UnPinBiCommand = new DelegateCommand<string>(ExecuteUnPinBiCommand));

        void ExecuteUnPinBiCommand(string parameter)
        {
            switch (parameter)
            {
                case "ST01屏蔽":
                    ST1Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST02屏蔽":
                    ST2Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST03屏蔽":
                    ST3Station_Global.stationPCToPLC.bDisableBT = false;
                    break;

                case "ST04屏蔽":
                    ST4Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST05屏蔽":
                    ST5Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST06屏蔽":
                    ST6Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST08屏蔽":
                    ST8Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST10屏蔽":
                    ST10Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST11屏蔽":
                    ST11Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST12屏蔽":
                    ST12Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST13屏蔽":
                    ST13Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST14屏蔽":
                    ST14Station_Global.stationPCToPLC.bDisableBT = false;
                    break;
                case "ST15屏蔽":
                    ST15Station_Global.stationPCToPLC.bDisableBT = false;
                    break;

              
                case "LED灯关闭":
                    SystemPCToPLC_Global.bLEDPowerBtn = false;
                    break;
                case "蜂鸣器关闭":
                    break;


                

                case "机械臂上药屏蔽":
                    SystemPCToPLC_Global.bRobotDisableBtn = false;
                    break;
                case "ST1称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[1] = false;
                    break;
                case "ST2测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[2] = false;
                    break;
                case "ST5测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[3] = false;
                    break;
                case "ST5压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[4] = false;
                    break;
                case "ST6称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[5] = false;
                    break;
                case "ST10压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[6] = false;
                    break;
                case "ST11称屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[7] = false;
                    break;
                case "ST13测高屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[8] = false;
                    break;
                case "ST13压力屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[9] = false;
                    break;
                case "ST13外径屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[10] = false;
                    break;


                case "载具1屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[32] = false;
                    break;

                case "载具2屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[33] = false;
                    break;

                case "载具3屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[34] = false;
                    break;
                case "载具4屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[35] = false;
                    break;
                case "载具5屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[36] = false;
                    break;
                case "载具6屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[37] = false;
                    break;
                case "载具7屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[38] = false;
                    break;
                case "载具8屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[39] = false;
                    break;
                case "载具9屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[40] = false;
                    break;
                case "载具10屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[41] = false;
                    break;
                case "载具11屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[42] = false;
                    break;
                case "载具12屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[43] = false;
                    break;
                case "载具13屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[44] = false;
                    break;
                case "载具14屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[45] = false;
                    break;
                case "载具15屏蔽":
                    SystemPCToPLC_Global.bTestDisableBtn[46] = false;
                    break;
                case "安全门屏蔽":
                    SystemPCToPLC_Global.bDoorByPass=false;
                    break;
                default:
                    break;


            }
        }


        private DelegateCommand _PCDisabledDownCmd;
        public DelegateCommand PCDisabledDownCmd =>
            _PCDisabledDownCmd ?? (_PCDisabledDownCmd = new DelegateCommand(ExecutePCDisabledDownCmd));

        void ExecutePCDisabledDownCmd()
        {
            SystemPCToPLC_Global.bPcDisableBtn = true;
        }

        private DelegateCommand _PCDisabledUpCmd;
        public DelegateCommand PCDisabledUpCmd =>
            _PCDisabledUpCmd ?? (_PCDisabledUpCmd = new DelegateCommand(ExecutePCDisabledUpCmd));

        void ExecutePCDisabledUpCmd()
        {
            SystemPCToPLC_Global.bPcDisableBtn = false;

        }

       

        private DelegateCommand _DryRunDownCmd;
        public DelegateCommand DryRunDownCmd =>
            _DryRunDownCmd ?? (_DryRunDownCmd = new DelegateCommand(ExecuteDryRunDownCmd));

        void ExecuteDryRunDownCmd()
        {
            SystemPCToPLC_Global.bDryRunBtn = true;

        }

        private DelegateCommand _DryRunUpCmd;
        public DelegateCommand DryRunUpCmd =>
            _DryRunUpCmd ?? (_DryRunUpCmd = new DelegateCommand(ExecuteDryRunUpCmd));

        void ExecuteDryRunUpCmd()
        {
            SystemPCToPLC_Global.bDryRunBtn = false;

        }

        #region 
        private string _bPcDisabledText;
        public string bPcDisabledText
        {
            get { return _bPcDisabledText; }
            set { SetProperty(ref _bPcDisabledText, value); }
        }


        private string _bCcdDisabledText;
        public string bCcdDisabledText
        {
            get { return _bCcdDisabledText; }
            set { SetProperty(ref _bCcdDisabledText, value); }
        }


        private string _bDryRunningText;
        public string bDryRunningText
        {
            get { return _bDryRunningText; }
            set { SetProperty(ref _bDryRunningText, value); }
        }



        private bool _BoolDryRunning;
        public bool BoolDryRunning
        {
            get { return _BoolDryRunning; }
            set { SetProperty(ref _BoolDryRunning, value); }
        }

        private bool _BoolCCDDisabled;
        public bool BoolCCDDisabled
        {
            get { return _BoolCCDDisabled; }
            set { SetProperty(ref _BoolCCDDisabled, value); }
        }

        private bool _BoolPCDisabled;
        public bool BoolPCDisabled
        {
            get { return _BoolPCDisabled; }
            set { SetProperty(ref _BoolPCDisabled, value); }
        }
        #endregion
    }
}